package com.ruoyi.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.dao.CardMapper;
import com.ruoyi.pojo.ResultVo;
import com.ruoyi.pojo.SearchVo;
import com.ruoyi.pojo.TbCard;
import com.ruoyi.service.CardService;
import org.springframework.stereotype.Service;

@Service
public class CardServiceImpl extends ServiceImpl<CardMapper,TbCard> implements CardService {
    @Override
    public ResultVo searchList(SearchVo searchVo) {
        IPage<TbCard> page = new Page<>(searchVo.getPage(),searchVo.getSize());
        QueryWrapper<TbCard> query = new QueryWrapper<>();
        // 根据驾驶员名称模糊查询
        if (!StrUtil.isEmpty(searchVo.getDriver())) {
            query.like("driver",searchVo.getDriver());
        }
        // 根据状态查询
        if (!StrUtil.isEmpty(searchVo.getStatus())) {
            query.eq("status",searchVo.getStatus());
        }
        IPage<TbCard> result = this.baseMapper.selectPage(page, query);
        return new ResultVo(200, "查询成功", result);
    }
}
